<template>
  <div class="article">
    <ul>
      <div class="anim"></div>
      <li
        v-waves
        @click="handleClick(item.id)"
        v-for="(item, index) in articleList"
        :key="index"
      >
        <img src="@/assets/image/demo.jpg" alt="" />
        <div>
          <h2>{{ item.title }}</h2>
          <p>
            {{ item.text }}
          </p>
          <CutOff></CutOff>
        </div>
      </li>
    </ul>
  </div>
</template>

<script lamg='scss'>
import CutOff from "@/components/common/cut-off.vue";
// import { useRouter, useRoute } from "vue-router";
import router from "@/router/router";
export default {
  name: "article", //文章
  components: {
    CutOff,
  },
  props: {
    articleList: {
      type: Array,
      default: [],
    },
  },
  setup() {
    function handleClick(id) {
      console.log(id);
      // router.push({ params: 6, name: "Detail" });
       router.push('/detail?id=' + id);
      //  window.location.href='http://www.baidu.com'
    }
    return { handleClick };
    // 组合api，需要return出去
  },
};
</script>

<style lang='scss' scoped>
.article {
  li {
    display: flex;
    img {
      margin-right: 10px;
      width: 80px;
      height: 60px;
    }
    h2 {
      height: 30px;
      line-height: 30px;
      font-size: 16px;
      color: #333;
    }
    p {
      color: #999;
    }
  }
}
</style>